import { Injectable } from '@nestjs/common';
import { STS } from 'ali-oss';

@Injectable()
export class UploadService {
  private stsClient: STS;

  constructor() {
    this.stsClient = new STS({
      accessKeyId: 'LTAI5t6mUNJ7jgnX4mywtTfS',
      accessKeySecret: '9H0kAofCLmwuUkUMUNmn2hPWei5zN4',
    });
  }

  async generateTemporaryCredentials() {
    const res = await this.stsClient.assumeRole(
      'acs:ram::1526237640159728:role/h5',
      '',
      3000,
      'session',
    );
    return res.credentials;
  }
}
